$(document).ready(function() {
	$('#rolesTable').dataTable({
		"bFilter" : false,
		 "bLengthChange": false,
		"bStateSave" : false,
		"bSort": false,	
		"bInfo": false,
		"sPaginationType" : "bootstrap",
		"oLanguage" : {
			"sLengthMenu" : "Display _MENU_ records per page",
			"sZeroRecords" : "Nothing found - sorry",
			"sInfo" : "Showing _START_ to _END_ of _TOTAL_ records",
			"sInfoEmpty" : "Showing 0 to 0 of 0 records"
		},
		"bProcessing" : true,
		"bServerSide" : true,
		"sAjaxSource" : "companyEmployeesList",
		"aoColumns" : [ {"mData" : "fName" },
		                {"mData" : "id"}
		               ],
		"aoColumnDefs": [
						{"aTargets": [0],"mData": null,"mRender": function (data, type, full) {
							return "<strong style='color:#0088cc;'>"+data+"</strong>";
						}
						},
		                 {"aTargets": [1],"mData": null,"mRender": function (data, type, full) {
		                	 return  "<input type='radio' class='radioBtnClass' name='group1' value='"+data+"'/>";
		                 }
		                }]
	});
	$("#btnTransferSelectedLead").click(function() {
		var selectedCheckbox = $("input[name='group1']:checked").val();
		if (selectedCheckbox == null) {
	    	  $('#errorModalLabel').html('Warning:');
	    	  $('#errorModalMsg').html('Please select a record first.');
	    	  $('#errorModelBody').attr('class', 'modal-body alert alert-warning');
	    	  $('#errorModal').modal();
		} else {
			$('#deleteModalLabel').html('Warning:');
	    	  $('#deleteModalMsg').html('Are you sure you want to Tansfer this Lead ?');
	    	  $('#deleteModelBody').attr('class', 'modal-body alert alert-danger');
	    	  $('#deleteModel').modal();
	    	  $( "#btnDelete" ).click(function() {
	    		  var leadId = $("#leadId").val();
	    		  window.location = "transferLead?leadId="+leadId+"&empId="+selectedCheckbox+"";
	    		});
		}
	});
	
	$('#shareTable').dataTable({
		"bFilter" : false,
		 "bLengthChange": false,
		"bStateSave" : false,
		"bSort": false,	
		"bInfo": false,
		"sPaginationType" : "bootstrap",
		"oLanguage" : {
			"sLengthMenu" : "Display _MENU_ records per page",
			"sZeroRecords" : "Nothing found - sorry",
			"sInfo" : "Showing _START_ to _END_ of _TOTAL_ records",
			"sInfoEmpty" : "Showing 0 to 0 of 0 records"
		},
		"bProcessing" : true,
		"bServerSide" : true,
		"sAjaxSource" : "companyEmployeesList",
		"aoColumns" : [ {"mData" : "fName" },
		                {"mData" : "id"}
		               ],
		"aoColumnDefs": [
						{"aTargets": [0],"mData": null,"mRender": function (data, type, full) {
							return "<strong style='color:#0088cc;'>"+data+"</strong>";
						}
						},
		                 {"aTargets": [1],"mData": null,"mRender": function (data, type, full) {
		                	 return  "<input type='radio' class='radioBtnClass' name='group1' value='"+data+"'/>";
		                 }
		                }]
	});
	
	$("#btnShareSelectedLead").click(function() {
		var selectedCheckbox = $("input[name='group1']:checked").val();
		if (selectedCheckbox == null) {
	    	  $('#errorModalLabel').html('Warning:');
	    	  $('#errorModalMsg').html('Please select a record first.');
	    	  $('#errorModelBody').attr('class', 'modal-body alert alert-warning');
	    	  $('#errorModal').modal();
		} else {
			$('#deleteModalLabel').html('Warning:');
	    	  $('#deleteModalMsg').html('Are you sure you want to Tansfer this Lead ?');
	    	  $('#deleteModelBody').attr('class', 'modal-body alert alert-danger');
	    	  $('#deleteModel').modal();
	    	  $( "#btnDelete" ).click(function() {
	    		  var leadId = $("#leadId").val();
	    		  window.location = "shareLead?leadId="+leadId+"&empId="+selectedCheckbox+"";
	    		});
		}
	});
});